import bundleManager from '@ohos.bundle.bundleManager';
import ota_yxw from '@ohos.ota_yxw';
import emitter from '@ohos.events.emitter';

export default class CommonConstants {
    static readonly APP_VERSION: string = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT).versionName
    static readonly SERVER: string = 'http://iotapi.abupdate.com/'
    static readonly MID: string = ota_yxw.OTAgetSN()
    static readonly OEM: string = 'HRA'
    static readonly MODELS: string = 'HRA_HM_PRJ_1'
    static readonly PLATFORM: string = 'RK3568'
    static readonly DEVICES_TYPE: string = 'pad'
    static readonly PRODUCT_ID: string = '1726739608'
    static readonly PRODUCT_SECRET: string = 'aa71b698c3ea4ccba43f204457a713a7'

    static readonly PREFERENCES_NAME: string = 'HraOtaSettings'
    static readonly PRE_KEY_LAST_CHECK_DATE: string = 'last_check_date'
    static readonly PRE_KEY_CHECK_INTERVAL_INDEX: string = 'check_interval_index'
    static readonly PRE_KEY_WLAN_DOWNLOAD_ONLY: string = 'is_wlan_download_only'
    static readonly PRE_KEY_AUTO_DOWNLOAD: string = 'is_auto_download'
    static readonly ONE_DAY_MILLISECONDS: number = 24 * 60 * 60 * 1000
    static readonly INTERVAL_STRING_ARRAY: Array<string> = [
        '一天',
        '三天',
        '一周'
    ]
    static readonly INTERVAL_DELAY_ARRAY: Array<number> = [
        CommonConstants.ONE_DAY_MILLISECONDS,
        3 * CommonConstants.ONE_DAY_MILLISECONDS,
        7 * CommonConstants.ONE_DAY_MILLISECONDS
    ]

    static readonly MAX_DOWNLOAD_NUMBER: number = 6
    static readonly INNER_EVENT_ID: number = 1001
    static readonly INNER_EVENT: emitter.InnerEvent = {
        eventId: CommonConstants.INNER_EVENT_ID
    }
}

/**
 * 应用的状态
 */
export enum DownloadState {
    NONE,
    CHECKING,
    CHECKED,
    RUNNING,
    PAUSE,
    RESUME,
    COMPLETED,
    FAILED,
    NO_NETWORK,
    CANCEL
}

/**
 * 后台弹窗的类型
 */
export enum AlertType {
    DownloadAlert,
    InstallAlert
}

/**
 * EmitAction 的类型
 */
export enum EmitActionType {
    bgDownload,
    cancelAlert,
    selectedInterval
}
